#!/bin/bash
start_time=$(date +%s) # %s可以计算的是1970年以来的秒数

cd ../build/

for rg in 1 5 10 50 100 500; do
    # Request distributions
    for dist in zipfian; do
        sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
        ./read_cold -f ../db/dataset/amazon_reviews.txt -k 16 -v 64 -d ../ssd/db_ar_16_random -m 7 -u -n 10000 -i 5 --change_level_load $* --distribution ../db/ycsb/ycsb-c-33M-10M_${dist}_dist.txt --range ${rg} > ../evaluation/ar_16_llsm_${dist}_dist_${rg}.txt
        ./read_cold -f ../db/dataset/amazon_reviews.txt -k 16 -v 64 -d ../ssd/db_ar_16_random -m 8 -u -n 10000 -i 5 $* --distribution ../db/ycsb/ycsb-c-33M-10M_${dist}_dist.txt --range ${rg} > ../evaluation/ar_16_baseline_${dist}_dist_${rg}.txt
    done
    
    for dist in zipfian; do
        sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
        ./read_cold -f ../db/dataset/osm_ny.txt -k 16 -v 64 -d ../ssd/db_osm_16_random -m 7 -u -n 10000 -i 5 --change_level_load $* --distribution ../db/ycsb/ycsb-c-20M-10M_${dist}_dist.txt --range ${rg} > ../evaluation/osm_16_llsm_${dist}_dist_${rg}.txt
        ./read_cold -f ../db/dataset/osm_ny.txt -k 16 -v 64 -d ../ssd/db_osm_16_random -m 8 -u -n 10000 -i 5 $* --distribution ../db/ycsb/ycsb-c-20M-10M_${dist}_dist.txt --range ${rg} > ../evaluation/osm_16_baseline_${dist}_dist_${rg}.txt
    done
done

cd ../learned-leveldb/
python3 ./scripts/collect_results.py 6 > ../evaluation/expr_request_dist.txt
cat ../evaluation/expr_request_dist.txt


end_time=$(date +%s)
cost_time=$((end_time-start_time))
echo "build kernel time is $((cost_time/60))min $((cost_time%60))s"